<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title></title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" />
		<meta content="yes" name="apple-mobile-web-app-capable" />
		<link href="${BasePath}/course/css/bootstrap.min.css" rel="stylesheet" />
		<link href="${BasePath}/course/font-awesome/css/font-awesome.css?v=4.3.0" rel="stylesheet">
		<link href="${BasePath}/course/css/styles.css" rel="stylesheet" />
		<link href="${BasePath}/course/css/layer.css" rel="stylesheet" />
		<script type="text/javascript" src="${BasePath}/course/js/zepto.js"></script>
		<script type="text/javascript" src="${BasePath}/course/js/main.js"></script>
		<script type="text/javascript" src="${BasePath}/course/js/layer.js"></script>
	</head>
	<body>
		<div class="container width90">
			
			<!--音频播放的-->
			<div class="c-audio"><!--audio begin-->
				<#if (course.faceImgPath)?? >
					<div class="audio-img"><img src="${course.faceImgPath}"></div>
				<#else>
					<div class="audio-img"><img src="${course.imgPath}"></div>
				</#if>
				<div class="audio-desc">
					<h1>${course.title}</h1>
					<p>${course.nickName}</p>
				</div>
				<div class="audio-wrapper">
					
				    <audio>
				        <source src="${course.radioLink}" type="audio/mp3">
				    </audio>
				    <div class="audio-kz">
				    	 <div class="audio-time time-now"><span class="audio-length-current" id="audioCurTime">00:00</span></div>
				    	  <div class="audio-top">
				        
				        <div class="progress-bar-bg" id="progressBarBg"><span id="progressDot"></span>
				            <div class="progress-bar" id="progressBar"></div>
				        </div>
				       
				    </div>
				    	  <div class="audio-time time-end"><span id="endtime" class="audio-length-total ">01:06</span></div>
				    </div>
				   
				     <div class="audio-bottom">
						<div class="ab-item"><div class="abi-1"><i class=""></i><p></p></div></div>
				     	<div class="ab-item"><img  class="sp-img" id="audioBack" src="${BasePath}/course/images/houtui15s_u.png"></div>
				     	<div class="ab-item"><img class="sp-img" id="audioPlayer" src="${BasePath}/course/images/bofangjiemian_zanting.png"></div>
				     	<div class="ab-item"><img class="sp-img" id="audioBefore" src="${BasePath}/course/images/kuaijini15s_u.png"></div>
				     	<div class="ab-item"><div class="abi-1"><a href="${BasePath}/page/course/detail?id=${course.id}">
				     		<i class="fa fa-file-text-o"></i><p>查看文档</p>
				     	</a></div></div>
				     	
				     </div>
				</div>
				
			</div><!--audio end-->
			<!--留言评论区-->
			<div class="c-comment"><!--comment begin-->
				<div class="cc-title">
					<h2 class="fl" data-count="${commentCount}">留言精选（${commentCount}）</h2>
					
				</div>
				<#if (commentCount > 0)>
					<ul class="unstyled activitylist ctlist"></ul>
				</#if>
				
			</div><!--comment end-->
		</div>
		<#if (course.isFree == 0 && !course.isBuy)>
				<!--0924-->
				<div class="buylayer width100">
					<div id="autotype" autotype="0" style="display: none;"></div>
					<div class="blitem" id="testaudioPlayer"><img class="sp-img"  src="${BasePath}/course/images/bofang_shouye.png" >免费试听</div>
					<div class="blitem bl2" id="gotologin">购买课程(${course.price}氧币)</div>
				</div>
		</#if>

		<script type="text/javascript" src="${BasePath}/js/jquery-3.3.1.min.js"></script>
		<script type="text/javascript" src="${BasePath}/js/weixinAjaxHeader.js"></script>
		<script>
			if("${course.isFree}" == 0 && "${isBuy}" == 1){
                $(".audio-wrapper").addClass("noclick"); //这一句是禁止音频按钮点击的 
            }
		<!--0924end-->
            function getComment(pageNum){
                var ret = false;
                var requestData = {
                    "courseId":"${course.id}",
					"pageNum":pageNum,
					"pageSize":10
				};
                console.log("request data:" + JSON.stringify(requestData));
                $.ajax({
                    type: 'post',
                    cache:false,
                    async:false,
                    url: "${BasePath}/api/comment/list",
                    data: JSON.stringify({"requestData":JSON.stringify(requestData)}),
                    dataType: "json",
					contentType : "application/json",
                    success: function(data){
                        console.log("response data:" + JSON.stringify(data));
                        if(data.code == 200){
                            ret = data.responseData;
                        }
                    },
                    error: function(request) {
                        prompt($(".prompt"), "系统繁忙，请稍候重试！");
                    }
                });
                return ret;
            }
            $("#gotologin").click(function(){
                if("${isLogin}" == 0){
                    layer.open({
                        content: '正在购买'
                        ,skin: 'msg'
                        ,time: 1 //1秒后自动关闭
                    });
                    var buyResult = buy();
                    console.log(buyResult);
                    if(buyResult){
                        var orderId = JSON.parse(buyResult).id;
                        var payResult = pay(orderId);
                        if(payResult){
                            $(".buylayer").css('display','none');
                            $(".audio-wrapper").removeClass("noclick");
                        }
					}
                }
                else
                {
                    window.location.href = "${BasePath}/page/weixin/login";
                }
			});
			function buy(){
                var ret = false;
                var requestData = {
                    "courseId":"${course.id}",
                    "memberId": "${memberId}"
                };
                console.log("request data:" + JSON.stringify(requestData));
                $.ajax({
                    type: 'post',
                    cache:false,
                    async:false,
                    url: "${BasePath}/api/course/buy",
                    data: JSON.stringify({"requestData":JSON.stringify(requestData)}),
                    dataType: "json",
                    contentType : "application/json",
                    success: function(data){
                        console.log("response data:" + JSON.stringify(data));
                        if(data.code == 200){
                            ret = data.responseData;
                        }else{
                            //prompt($(".prompt"), data.error);
                            layer.open({
                                content: data.error
                                ,skin: 'msg'
                                ,time: 1 //1秒后自动关闭
                            });
						}
                    },
                    error: function(request) {
                        prompt($(".prompt"), "系统繁忙，请稍候重试！");
                    }
                });
                return ret;
			}
			function pay(orderId){
                var ret = false;
                var requestData = {
                    "courseOrderId":orderId,
                    "coinCount":"${course.price}"
                };
                console.log("request data:" + JSON.stringify(requestData));
                $.ajax({
                    type: 'post',
                    cache:false,
                    async:false,
                    url: "${BasePath}/api/coin/pay",
                    data: JSON.stringify({"requestData":JSON.stringify(requestData)}),
                    dataType: "json",
                    contentType : "application/json",
                    success: function(data){
                        console.log("response data:" + JSON.stringify(data));
                        if(data.code == 200){
                            ret = data.responseData;
                        }else{
                            layer.open({
                                content: data.error
                                ,skin: 'msg'
                                ,time: 1 //1秒后自动关闭
                            });
						}
                    },
                    error: function(request) {
                        prompt($(".prompt"), "系统繁忙，请稍候重试！");
                    }
                });
                return ret;
			}
		</script>
	</body>
</html>
